import React from 'react';
import { connect } from 'dva'
import queryString from 'query-string'
import {
  Card,
} from 'antd'
import List from "./salesDistributorRegistryApplyList";
import StoreFastModal from "./StoreFastModal";
import StoreDetailModal from './StoreDetailModal';
import PageHeaderLayout from 'components/Layout/PageHeaderLayout';
import OrderFilterUnExpand from 'components/Filter/GeneralFilter';

const salesDistributorRegistryApplys = ({ location, dispatch, salesDistributorRegistryApply, storelist, app, loading }) => {
  location.query = queryString.parse(location.search);
  const { items, currentItem, pagination, detailVisible, currentOption,fastVisible,commodityStoreList, isExpand, auditVisible, editVisible, auditItem, typeObj } = salesDistributorRegistryApply;
  const breadcrumbList = [
    {
      title: '入驻管理',

    }, {
      title: '入驻申请审核',

    }
  ];
  const listProps = {
    dataSource: items,
    loading: loading.global,
    pagination,
    pageChangeAction: 'salesDistributorRegistryApply/query',
    dispatch,
    global: loading.global,
    location,
    typeObj
  };
  const filterProps = {
    filterItems: [
      {
        type: 'input',
        id: 'mobile',
        title: '手机号码'
      },
      {
        type: 'input',
        id: 'userIdentityNum',
        title: '身份证号码'
      },
      {
        type: 'select',
        id: 'auditStatus',
        title: '审核状态',
        options: [
          {
            value: "",
            name: '全部'
          }, {
            value: 'PENDING',
            name: '等待审核'
          }, {
            value: 'AUDIT_SUCCESS',
            name: '审核成功'
          }, {
            value: 'AUDIT_FAIL',
            name: '审核失败'
          }
        ],
        defaultValue: ""
      }
    ],
    onFilterChange(value) {
      dispatch({
        type: 'salesDistributorRegistryApply/query',
        payload: {
          ...value
        }
      })
    },
    isExpand,
    noExpand() {
      dispatch({ type: 'salesDistributorRegistryApply/unExpandFilter', payload: {} })
    },
    expand() {
      dispatch({ type: 'salesDistributorRegistryApply/expandFilter', payload: {} })
    },
    Col: 6
  }

  const detailProps = {
    currentItem: currentItem,
    auditItem: auditItem,
    detailVisible: detailVisible,
    auditVisible: auditVisible,
    editVisible: editVisible,
    dispatch,
    loading
  }

  return (
    <PageHeaderLayout title="入驻审核申请" breadcrumbList={breadcrumbList}>
      <Card bordered={false}>
        <StoreFastModal visible={fastVisible} dispatch={dispatch} currentItem={currentItem} loading={loading} commodityStoreList={commodityStoreList} currentOption={currentOption} />
        <OrderFilterUnExpand {...filterProps} />
        <StoreDetailModal {...detailProps} />

        <List effects={loading.effects} {...listProps} />

      </Card>
    </PageHeaderLayout>
  )
};
export default connect(({ salesDistributorRegistryApply, storelist, app, loading, load }) => ({ salesDistributorRegistryApply, storelist, app, loading, load }))(salesDistributorRegistryApplys)

